using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Tools;
using Pixysoft.Framework.Verifications;
using Pixysoft.Framework.Noebe;
using Pixysoft.Weblications.Sango.Entities;

namespace Pixysoft.Weblications.Sango.Environment
{

    public class SysOfficerHelper
    {
        private static List<Sys_Officer> orms = new List<Sys_Officer>();

        public static void initialize()
        {
            orms = SettingHelper.GetNoebe().EntityNoebeCommand.Select<Sys_Officer>();

            LoggerHelper.Info("initialize Sys_Officer.countin {0}", orms.Count);
        }

        public static Sys_Officer searchBySerialcode(long serialcode)
        {
            foreach (Sys_Officer orm in orms)
            {
                if (orm.Officerserialcode == serialcode)
                    return orm;
            }

            throw Exceptions.VerificationFailedException(serialcode);
        }

        public static Sys_Officer searchByAvatarcode(long avatarcode)
        {
            foreach (Sys_Officer orm in orms)
            {
                if (orm.Avatarcode == avatarcode)
                    return orm;
            }

            throw Exceptions.VerificationFailedException(avatarcode);
        }
    }
}